package com.threegroup.android3grouppersonality.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;

import com.threegroup.android3grouppersonality.R;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentMessage.CommentMsgListFragment;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentMessage.FriendListFragment;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentMessage.LikeMsgListFragment;


public class MessageFragment extends Fragment implements View.OnClickListener {
    /*
     * 此Fragment应有的功能
     * 1、好友列表（FriendActiviyty）:内包含一个Adapter显示
     * */
    private ImageView iv_myfriends;
    private FriendListFragment friendListFragment;
    private ImageView iv_plmessage;

    private CommentMsgListFragment commentMsgListFragment;
private LikeMsgListFragment likeMsgListFragment;
private ImageView iv_dzmesage;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_messang, container, false);
        friendListFragment = new FriendListFragment();
        commentMsgListFragment = new CommentMsgListFragment();
        likeMsgListFragment=new LikeMsgListFragment();
        iv_myfriends = view.findViewById(R.id.iv_myfriends);
        iv_myfriends.setOnClickListener(this);
        iv_plmessage = view.findViewById(R.id.iv_plmessage);
        iv_plmessage.setOnClickListener(this);
        iv_dzmesage = view.findViewById(R.id.iv_dzmesage);
        iv_dzmesage.setOnClickListener(this);
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_messagecontext, friendListFragment).commit();
        return view;
    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.iv_myfriends:
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_messagecontext, friendListFragment).commit();
                break;

            case R.id.iv_plmessage:
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_messagecontext, commentMsgListFragment).commit();
                break;

            case R.id.iv_dzmesage:
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_messagecontext, likeMsgListFragment).commit();
                break;
        }
    }
}
